import deviceListJson from '@/json/device.json'

//设备列表
export const deviceListApi = async (obj) => {
	const deviceList = filterDevicesByName(obj.name)
	let currentPage = obj.page
	let devicesPerPage = obj.limit
	// 计算总页数
	let totalPages = Math.ceil(deviceList.length / devicesPerPage);
	let startIndex = (currentPage - 1) * devicesPerPage;
	let endIndex = startIndex + devicesPerPage;
	return deviceList.slice(startIndex, endIndex);
}

// 示例：根据名称过滤设备列表
const filterDevicesByName = (name) => {
  return deviceListJson.filter(function(device) {
    return device.name.toLowerCase().includes(name.toLowerCase());
  });
}